package com.zretc.service.impl;
import com.zretc.dao.FamilyMapper;
import com.zretc.pojo.FamilyInfo;
import com.zretc.service.FamilyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class FamilyServiceImpl implements FamilyService {
    @Autowired
    private FamilyMapper familyMapper;

    /**
     * 查询多条
     * @param idCard
     * @return
     */
    @Override
    public List<FamilyInfo> getFamilyInfo(String idCard) {
        return familyMapper.getFamilyInfo(idCard);
    }

    /**
     * 新增
     * @param familyInfo
     * @return
     */
//    从事务方法中抛出的Checked exceptions进行回滚：在整个方法前加上 @Transactional(rollbackFor=Exception.class)
    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer addFamilyInfo(FamilyInfo familyInfo) {
        return familyMapper.addFamilyInfo(familyInfo);
    }

    /**
     * 查询一条
     * @param familyId
     * @return
     */
    @Override
    public FamilyInfo selectIdFamilyInfo(Integer familyId) {
        return familyMapper.selectIdFamilyInfo(familyId);
    }

    /**
     * 修改信息
     * @param familyInfo
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer editFamilyInfo(FamilyInfo familyInfo) {
        return familyMapper.editFamilyInfo(familyInfo);
    }

    /**
     * 删除信息
     * @param familyId
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer deleteFamilyInfo(Integer familyId) {
        return familyMapper.deleteFamilyInfo(familyId);
    }


}
